update_spacings (GTK_DIALOG (widget));
}
-static GtkWidget *
-dialog_find_button (GtkDialog *dialog,
- gint response_id)
-{
- GtkWidget *child = NULL;
- GList *children, *tmp_list;
-
- children = get_action_children (dialog);
-
- for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
- {
- ResponseData *rd = get_response_data (tmp_list->data, FALSE);
-
- if (rd && rd->response_id == response_id)
- {
- child = tmp_list->data;
- break;
- }
- }
-
- g_list_free (children);
-
- return child;
-}
-
static void
gtk_dialog_close (GtkDialog *dialog)
{
button = gtk_button_new_with_label (button_text);
gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (button_text)
- {
- GtkStockItem item;
- if (gtk_stock_lookup (button_text, &item))
- g_object_set (button, "use-stock", TRUE, NULL);
- }
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
gtk_widget_set_can_default (button, TRUE);
return rd->response_id;
}
-static gboolean
-gtk_alt_dialog_button_order (void)
-{
- gboolean result;
- g_object_get (gtk_settings_get_default (),
- "gtk-alternative-button-order", &result, NULL);
- return result;
-}
-
-/**
- * gtk_alternative_dialog_button_order:
- * @screen: (allow-none): a #GdkScreen, or %NULL to use the default screen
- *
- * Returns %TRUE if dialogs are expected to use an alternative
- * button order on the screen @screen. See
- * gtk_dialog_set_alternative_button_order() for more details
- * about alternative button order.
- *
- * If you need to use this function, you should probably connect
- * to the ::notify:gtk-alternative-button-order signal on the
- * #GtkSettings object associated to @screen, in order to be
- * notified if the button order setting changes.
- *
- * Returns: Whether the alternative button order should be used
- *
- * Since: 2.6
- * Deprecated: 3.10: Deprecated
- */
-gboolean
-gtk_alternative_dialog_button_order (GdkScreen *screen)
-{
- return gtk_alt_dialog_button_order ();
-}
-
-static void
-gtk_dialog_set_alternative_button_order_valist (GtkDialog *dialog,
- gint first_response_id,
- va_list args)
-{
- GtkDialogPrivate *priv = dialog->priv;
- GtkWidget *child;
- gint response_id;
- gint position;
-
- response_id = first_response_id;
- position = 0;
- while (response_id != -1)
- {
- /* reorder child with response_id to position */
- child = dialog_find_button (dialog, response_id);
- if (child != NULL)
- gtk_box_reorder_child (GTK_BOX (priv->action_area), child, position);
- else
- g_warning ("%s : no child button with response id %d.", G_STRFUNC,
- response_id);
-
- response_id = va_arg (args, gint);
- position++;
- }
-}
-
-/**
- * gtk_dialog_set_alternative_button_order:
- * @dialog: a #GtkDialog
- * @first_response_id: a response id used by one @dialog’s buttons
- * @...: a list of more response ids of @dialog’s buttons, terminated by -1
- *
- * Sets an alternative button order. If the
- * #GtkSettings:gtk-alternative-button-order setting is set to %TRUE,
- * the dialog buttons are reordered according to the order of the
- * response ids passed to this function.
- *
- * By default, GTK+ dialogs use the button order advocated by the
- * [GNOME Human Interface Guidelines](http://library.gnome.org/devel/hig-book/stable/)
- * with the affirmative button at the far
- * right, and the cancel button left of it. But the builtin GTK+ dialogs
- * and #GtkMessageDialogs do provide an alternative button order,
- * which is more suitable on some platforms, e.g. Windows.
- *
- * Use this function after adding all the buttons to your dialog, as the
- * following example shows:
- *
- * |[<!-- language="C" -->
- * cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- * _("_Cancel"),
- * GTK_RESPONSE_CANCEL);
- *
- * ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- * _("_OK"),
- * GTK_RESPONSE_OK);
- *
- * gtk_widget_grab_default (ok_button);
- *
- * help_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
- * _("_Help"),
- * GTK_RESPONSE_HELP);
- *
- * gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- * GTK_RESPONSE_OK,
- * GTK_RESPONSE_CANCEL,
- * GTK_RESPONSE_HELP,
- * -1);
- * ]|
- *
- * Since: 2.6
- * Deprecated: 3.10: Deprecated
- */
-void
-gtk_dialog_set_alternative_button_order (GtkDialog *dialog,
- gint first_response_id,
- ...)
-{
- GtkDialogPrivate *priv = dialog->priv;
- va_list args;
-
- g_return_if_fail (GTK_IS_DIALOG (dialog));
-
- if (priv->constructed && priv->use_header_bar)
- return;
-
- if (!gtk_alt_dialog_button_order ())
- return;
-
- va_start (args, first_response_id);
-
- gtk_dialog_set_alternative_button_order_valist (dialog,
- first_response_id,
- args);
- va_end (args);
-}
-/**
- * gtk_dialog_set_alternative_button_order_from_array:
- * @dialog: a #GtkDialog
- * @n_params: the number of response ids in @new_order
- * @new_order: (array length=n_params): an array of response ids of
- * @dialog’s buttons
- *
- * Sets an alternative button order. If the
- * #GtkSettings:gtk-alternative-button-order setting is set to %TRUE,
- * the dialog buttons are reordered according to the order of the
- * response ids in @new_order.
- *
- * See gtk_dialog_set_alternative_button_order() for more information.
- *
- * This function is for use by language bindings.
- *
- * Since: 2.6
- * Deprecated: 3.10: Deprecated
- */
-void
-gtk_dialog_set_alternative_button_order_from_array (GtkDialog *dialog,
- gint n_params,
- gint *new_order)
-{
- GtkDialogPrivate *priv = dialog->priv;
- GtkWidget *child;
- gint position;
-
- g_return_if_fail (GTK_IS_DIALOG (dialog));
- g_return_if_fail (new_order != NULL);
-
- if (dialog->priv->use_header_bar)
- return;
-
- if (!gtk_alt_dialog_button_order ())
- return;
-
- for (position = 0; position < n_params; position++)
- {
- /* reorder child with response_id to position */
- child = dialog_find_button (dialog, new_order[position]);
- if (child != NULL)
- gtk_box_reorder_child (GTK_BOX (priv->action_area), child, position);
- else
- g_warning ("%s : no child button with response id %d.", G_STRFUNC,
- new_order[position]);
- }
-}
-
typedef struct {
gchar *widget_name;
gint response_id;